<template>
  <div class="food-container">
    <!-- 头部banner -->
    <div class="food-banner">
      <div class="banner-content">
        <h1 class="banner-title">探索全球美食之旅</h1>
        <p class="banner-subtitle">品味世界各地的美食文化，学习经典菜肴制作</p>
      </div>
    </div>

    <!-- 内容分类标签 -->
    <div class="food-categories">
      <button 
        v-for="category in categories" 
        :key="category.id"
        class="category-tab"
        :class="{ active: activeCategory === category.id }"
        @click="activeCategory = category.id"
      >
        {{ category.name }}
      </button>
    </div>

    <!-- 推荐视频区域 -->
    <div class="recommended-section">
      <div class="section-header">
        <h2>热门推荐</h2>
        <a href="#" class="more-link">查看更多 <i class="fa fa-angle-right"></i></a>
      </div>
      <div class="video-grid featured-videos">
        <VideoCard 
          v-for="video in featuredVideos" 
          :key="video.id"
          :video="video"
        ></VideoCard>
      </div>
    </div>

    <!-- 全球美食区域 -->
    <div class="global-food-section">
      <div class="section-header">
        <h2>全球美食探索</h2>
        <div class="country-filter">
          <button 
            v-for="country in countries" 
            :key="country.code"
            class="country-tag"
            :class="{ active: selectedCountry === country.code }"
            @click="selectedCountry = country.code"
          >
            {{ country.name }}
          </button>
        </div>
      </div>
      <div class="video-grid global-videos">
        <VideoCard 
          v-for="video in globalFoodVideos" 
          :key="video.id"
          :video="video"
        ></VideoCard>
      </div>
    </div>

    <!-- 美食鉴赏区域 -->
    <div class="food-appreciation-section">
      <div class="section-header">
        <h2>美食鉴赏</h2>
        <a href="#" class="more-link">查看更多 <i class="fa fa-angle-right"></i></a>
      </div>
      <div class="video-grid appreciation-videos">
        <VideoCard 
          v-for="video in appreciationVideos" 
          :key="video.id"
          :video="video"
        ></VideoCard>
      </div>
    </div>

    <!-- 美食达人区域 -->
    <div class="food-experts-section">
      <div class="section-header">
        <h2>美食达人</h2>
      </div>
      <div class="experts-grid">
        <div v-for="expert in foodExperts" :key="expert.id" class="expert-card">
          <img :src="expert.avatar" :alt="expert.name" class="expert-avatar">
          <h3 class="expert-name">{{ expert.name }}</h3>
          <p class="expert-title">{{ expert.title }}</p>
          <div class="expert-stats">
            <span>{{ expert.followers }} 粉丝</span>
            <span>{{ expert.videos }} 视频</span>
          </div>
          <button class="follow-btn">关注</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import VideoCard from '../components/VideoCard.vue'
import logoImage from '@/assets/logo.png'

export default {
  name: 'FoodView',
  components: {
    VideoCard,
  },
  data() {
    return {
      activeCategory: 'all',
      selectedCountry: 'all',
      categories: [
        { id: 'all', name: '全部美食' },
        { id: 'chinese', name: '中餐' },
        { id: 'western', name: '西餐' },
        { id: 'dessert', name: '甜点烘焙' },
        { id: 'street', name: '街头小吃' },
        { id: 'health', name: '健康饮食' },
      ],
      countries: [
        { code: 'all', name: '全部国家' },
        { code: 'cn', name: '中国' },
        { code: 'jp', name: '日本' },
        { code: 'kr', name: '韩国' },
        { code: 'us', name: '美国' },
        { code: 'fr', name: '法国' },
        { code: 'it', name: '意大利' },
        { code: 'th', name: '泰国' },
      ],
      featuredVideos: [
        {
          id: 1,
          title: '舌尖上的中国：八大菜系经典菜肴制作',
          cover: '@/assets/二次元美食节海报_3.jpg',
          duration: '08:45',
          views: '2.3万',
          likes: '1.5万',
          author: '美食小当家',
          authorAvatar: logoImage,
        },
        {
          id: 2,
          title: '法国米其林三星大厨教你做经典牛排',
          cover: '@/assets/喜剧电影.jpeg',
          duration: '12:30',
          views: '1.8万',
          likes: '9.8千',
          author: '西餐大师',
          authorAvatar: logoImage,
        },
        {
          id: 3,
          title: '日本寿司大师的独家秘方揭秘',
          cover: '@/assets/科技数码展宣传图.jpg',
          duration: '15:20',
          views: '3.5万',
          likes: '2.1万',
          author: '日料研究室',
          authorAvatar: logoImage,
        },
        {
          id: 4,
          title: '网红甜品：脏脏包制作教程',
          cover: '@/assets/周杰伦.png',
          duration: '09:10',
          views: '5.2万',
          likes: '3.8万',
          author: '甜品控',
          authorAvatar: logoImage,
        },
      ],
      globalFoodVideos: [
        {
          id: 5,
          title: '意大利威尼斯：正宗手工意面制作',
          cover: '@/assets/动漫.png',
          duration: '10:45',
          views: '1.6万',
          likes: '8.7千',
          author: '环球美食',
          authorAvatar: logoImage,
        },
        {
          id: 6,
          title: '泰国曼谷街头美食全攻略',
          cover: '@/assets/悟空.jpg',
          duration: '14:20',
          views: '2.8万',
          likes: '1.7万',
          author: '旅行美食家',
          authorAvatar: logoImage,
        },
        {
          id: 7,
          title: '韩国首尔：韩式烤肉完全指南',
          cover: '@/assets/鬼灭之刃.jpeg',
          duration: '11:35',
          views: '2.1万',
          likes: '1.3万',
          author: '韩国美食之旅',
          authorAvatar: logoImage,
        },
        {
          id: 8,
          title: '中国四川：麻辣火锅底料秘方',
          cover: '@/assets/黑神话.jpeg',
          duration: '13:15',
          views: '4.2万',
          likes: '2.9万',
          author: '川菜大师',
          authorAvatar: logoImage,
        },
        {
          id: 9,
          title: '法国巴黎：马卡龙制作技巧',
          cover: '@/assets/二次元美食节海报_3.jpg',
          duration: '16:25',
          views: '1.9万',
          likes: '1.1万',
          author: '甜点大师班',
          authorAvatar: logoImage,
        },
        {
          id: 10,
          title: '美国纽约：经典汉堡制作秘方',
          cover: '@/assets/喜剧电影.jpeg',
          duration: '08:50',
          views: '3.1万',
          likes: '2.2万',
          author: '美式厨房',
          authorAvatar: logoImage,
        },
      ],
      appreciationVideos: [
        {
          id: 11,
          title: '葡萄酒品鉴：如何辨别优质红酒',
          cover: '@/assets/科技数码展宣传图.jpg',
          duration: '18:40',
          views: '1.5万',
          likes: '9.2千',
          author: '酒类鉴赏家',
          authorAvatar: logoImage,
        },
        {
          id: 12,
          title: '咖啡文化：全球顶级咖啡豆品鉴',
          cover: '@/assets/周杰伦.png',
          duration: '20:15',
          views: '2.3万',
          likes: '1.6万',
          author: '咖啡大师',
          authorAvatar: logoImage,
        },
        {
          id: 13,
          title: '茶叶品鉴：中国十大名茶介绍',
          cover: '@/assets/动漫.png',
          duration: '17:30',
          views: '2.7万',
          likes: '1.8万',
          author: '茶道文化',
          authorAvatar: logoImage,
        },
        {
          id: 14,
          title: '巧克力鉴赏：从可可豆到巧克力的旅程',
          cover: '@/assets/悟空.jpg',
          duration: '15:45',
          views: '1.9万',
          likes: '1.2万',
          author: '巧克力控',
          authorAvatar: logoImage,
        },
      ],
      foodExperts: [
        {
          id: 1,
          name: '张大厨',
          title: '川菜非遗传承人',
          avatar: logoImage,
          followers: '125万',
          videos: '320',
        },
        {
          id: 2,
          name: '李甜点师',
          title: '法国蓝带认证甜点师',
          avatar: logoImage,
          followers: '89万',
          videos: '215',
        },
        {
          id: 3,
          name: '王美食家',
          title: '环球美食旅行家',
          avatar: logoImage,
          followers: '156万',
          videos: '432',
        },
        {
          id: 4,
          name: '刘品酒师',
          title: '国际认证葡萄酒品鉴师',
          avatar: logoImage,
          followers: '67万',
          videos: '189',
        },
      ],
    }
  },
  computed: {
    filteredGlobalFoodVideos() {
      if (this.selectedCountry === 'all') {
        return this.globalFoodVideos
      }
      // 这里可以根据国家过滤视频，暂时返回全部
      return this.globalFoodVideos
    },
  },
  mounted() {
    // 页面加载时可以添加一些初始化逻辑
    console.log('美食页面加载完成')
  },
  methods: {
    // 可以添加视频点击、过滤等交互方法
    handleVideoClick(videoId) {
      this.$router.push(`/video/${videoId}`)
    },
  },
}
</script>

<style scoped>
.food-container {
  max-width: 1440px;
  margin: 0 auto;
  padding-bottom: 60px;
}

/* 头部banner样式 */
.food-banner {
  height: 400px;
  background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('@/assets/二次元美食节海报_3.jpg') center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  text-align: center;
  margin-bottom: 40px;
}

.banner-content {
  max-width: 800px;
  padding: 0 20px;
}

.banner-title {
  font-size: 48px;
  font-weight: bold;
  margin-bottom: 16px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.banner-subtitle {
  font-size: 20px;
  opacity: 0.9;
}

/* 分类标签样式 */
.food-categories {
  display: flex;
  gap: 16px;
  padding: 0 20px;
  margin-bottom: 40px;
  overflow-x: auto;
  scrollbar-width: none;
}

.food-categories::-webkit-scrollbar {
  display: none;
}

.category-tab {
  padding: 8px 20px;
  background-color: #f5f5f5;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.category-tab:hover {
  background-color: #e8e8e8;
}

.category-tab.active {
  background-color: #ff4d6a;
  color: white;
}

/* 通用区域样式 */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  margin-bottom: 24px;
}

.section-header h2 {
  font-size: 24px;
  font-weight: bold;
  margin: 0;
}

.more-link {
  color: #666;
  text-decoration: none;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.more-link:hover {
  color: #ff4d6a;
}

/* 视频网格样式 */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  padding: 0 20px;
}

/* 国家筛选标签样式 */
.country-filter {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.country-tag {
  padding: 6px 16px;
  background-color: transparent;
  border: 1px solid #ddd;
  border-radius: 16px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
}

.country-tag:hover {
  border-color: #ff4d6a;
  color: #ff4d6a;
}

.country-tag.active {
  background-color: #ff4d6a;
  color: white;
  border-color: #ff4d6a;
}

/* 美食达人区域样式 */
.food-experts-section {
  margin-top: 60px;
}

.experts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
  padding: 0 20px;
}

.expert-card {
  text-align: center;
  padding: 20px;
  background-color: #f9f9f9;
  border-radius: 12px;
  transition: transform 0.3s ease;
}

.expert-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.expert-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 12px;
}

.expert-name {
  font-size: 18px;
  font-weight: bold;
  margin: 0 0 4px 0;
}

.expert-title {
  font-size: 14px;
  color: #666;
  margin: 0 0 12px 0;
}

.expert-stats {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #999;
}

.follow-btn {
  padding: 6px 24px;
  background-color: #ff4d6a;
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s ease;
}

.follow-btn:hover {
  background-color: #e6455a;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .banner-title {
    font-size: 36px;
  }
  
  .banner-subtitle {
    font-size: 16px;
  }
  
  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
  
  .experts-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
  }
}
</style>